#ifndef __ULCORE_BINFILE_H__
#define __ULCORE_BINFILE_H__

//Binary history data file format
//<Total Serials><Latest Serial Number><First Serial>...<Last Serial>
#include "ULCore_Serial.h"
#include <vector>

typedef struct {
	int totalSerials;
	int latestSerial;
}ULC_BinFileHeader;


typedef struct {
	int sn;
        char date[DATE_ALIGN_SIZE];
	int sortedBalls[UL_RED_BALLS_COUNT + 1];
	int actualOutBalls[UL_RED_BALLS_COUNT];
	int extraData[EXTRA_DATA_SIZE];
	struct hitsAndPrize top;
	struct hitsAndPrize second;
	struct hitsAndPrize third;
	struct hitsAndPrize fourth;
	struct hitsAndPrize fifth;
	struct hitsAndPrize sixth;
}ULC_BinFileSerial;

namespace ULC_BinFile{
	//Create a binary data file, if the file exists, the file will be truncated
	int SaveSerials(const char *fileName, int totalSerials, ULC_Serial *serials);	
	int LoadSerials(const char *fileName, ULC_Serial *serials);
	int GetTotalSerials(const char *fileName);
	int GetLatestSerial(const char *fileName);
	int AppendSingleSerial(const char *fileName, ULC_Serial &serial);
	int AppendSerials(const char *fileName, int nSerials, ULC_Serial *serials);
};

#endif /*__ULCORE_BINFILE_H__*/
